# 1. copy the mock data
f1=c03-chain.tmp.json
f2=c04-title.tmp.json
mv -v /home/me/Downloads/aixcoder-chain.json front3/src/assets/${f1}
mv -v /home/me/Downloads/aixcoder-title.json front3/src/assets/${f2}

# 2. start mock chain with the mock data
rm -rv zero
rm hi.jsonl
cd bk
dotnet run --mock-rest \
       --archive-folder=/home/me/repo/work/n3c/ --listening-address=http://0.0.0.0:5024 \
       --mock-infos=/home/me/repo/work/n3c/front3/src/assets/${f2} \
       --mock-t=/home/me/repo/work/n3c/front3/src/assets/${f1}

# 2a. mock grpc
n=/home/me/repo/work/n3c/
rm -v $n/hi.jsonl
rm -rv $n/zero
dotnet run --archive-folder=$n --listening-address=http://0.0.0.0:5024

# 2b. start the semi-mocked version
proxy_off
n=/home/me/repo/work/n3c/
rm -v $n/hi.jsonl
rm -rv $n/zero
dotnet run --mock-f2 --mock-f4 \
       --back-grpc=http://192.168.1.181:50052 \
       --archive-folder=$n --listening-address=http://0.0.0.0:5024

# H3C
ping 10.48.169.238
n=/home/me/repo/work/n3c/
dotnet run --mock-f2 --mock-f4 \
       --back-grpc=http://10.48.169.238:50052 \
       --n-parallel=2 \
       --archive-folder=$n --listening-address=http://0.0.0.0:5024
rm -rv wwwroot
ln -s ../front3/dist wwwroot

# --------------------------------------------------
# test things
bk/

m=TT
dotnet test --list-tests
dotnet test --filter "FullyQualifiedName~${m}" --logger "console;verbosity=normal" -p:DefineConstants="MY_TEST"
dotnet test --filter "FullyQualifiedName~T02" --logger "console;verbosity=normal" -p:DefineConstants="MY_TEST"
# --------------------------------------------------
# 🦜 : turn off the proxy before starting the server..
proxy_off

dotnet run
dotnet run

# 🦜 : method 1:

dotnet run --urls="https://localhost:7777"
# method 2:
cat Properties/launchSettings.json # 🦜 : edit this
http://localhost:5024/swagger/index.html
# ASPNETCORE_URLS=http://localhost:3000 dotnet run

cd front3
# vite --mode?
# https://vite.dev/guide/env-and-mode.html
# 🦜 : So "Mode" is kinda lika configuration profile.. By default there're two: "development" and "production". This Admin ui Created two more... which we're gonna remove.
rm -v .env.*
cat > .env.development <<- EOF
NODE_ENV = 'development'
VUE_APP_BASE_API = 'http://localhost:5024/api/'
VUE_APP_COOKIE = ''
EOF

cat > .env.production <<- EOF
NODE_ENV = 'production'
VUE_APP_BASE_API = '/'
EOF



# --------------------------------------------------
# deploy
# 1. build the front end
cd front3
npm run dev
npm run build
# 2. copy the build to the backend
rm -rvf ../bk/wwwroot/*
cp -vr dist/* ../bk/wwwroot/

# 3. run the backend and test the front end
cd ../bk
dotnet run -- --mock-rest --archive-folder=/home/me/repo/work/n3c/ --listening-address=http://0.0.0.0:5024

dotnet run -- --archive-folder=/home/me/repo/work/n3c/ --listening-address=http://0.0.0.0:5024

# 4. build the backend as well
file bin/Release/net8.0/bk.dll


# 5. run the backend
dotnet bin/Release/net8.0/bk.dll --mock-rest --archive-folder=/home/me/repo/work/n3c/ --listening-address=http://0.0.0.0:5024

dotnet bin/Release/net8.0/bk.dll --mock-rest \
       --archive-folder=/home/me/repo/work/n3c/ --listening-address=http://0.0.0.0:5024 \
       --mock-infos=/home/me/repo/work/n3c/front3/src/c02-posts.tmp.json \
       --mock-t=/home/me/repo/work/n3c/bk/T.json
